Why is i-- faster than i++ in loops? [closed]

Posted by Afshin Mehrabani on Stack Overflow See other posts from Stack Overflow or by Afshin Mehrabani
Published on 2012-10-30T10:09:43Z Indexed on 2012/11/26 23:04 UTC
Read the original article Hit count: 116

Possible Duplicate:
JavaScript - Are loops really faster in reverse…?

I don't know if this question is valid in other languages or not, but I'm asking this specifically for JavaScript.

I see in some articles and questions that the fastest loop in JavaScript is something like:

for(var i = array.length; i--; )

Also in Sublime Text 2, when you try to write a loop, it suggests:

for (var i = Things.length - 1; i >= 0; i--) {
    Things[i]
};

I want to know, why is i-- faster than i++ in loops?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about Performance